{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3291
  Verdict: Accepted
}
var a,b,n,k,x,r1,r2:longint;
procedure swap(var a,b:longint);
var t:longint;
begin
t:=a;
a:=b;
b:=t;
end;
function max(a,b:longint):longint;
begin
if a>b then result:=a else result:=b;
end;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,k,a,b);
inc(n);
if n<k then swap(n,k);
r1:=0;
r2:=0;
x:=a;
inc(r1,n*(x div ((n-1)*b)));
dec(x,b*(n-1)*(x div ((n-1)*b)));
inc(r1,k*(x div ((k-1)*b)));
dec(x,(k-1)*b*(x div ((k-1)*b)));
inc(r1,x div b);
x:=a;
inc(r2,k*(x div ((k-1)*b)));
dec(x,(k-1)*b*(x div ((k-1)*b)));
inc(r2,x div b);
dec(x,(x div b)*b);
write(max(r1,r2));
end.